home *** CD-ROM | disk | FTP | other *** search
/ TPUG - Toronto PET Users Group / TPUG Users Group CD / TPUG Users Group CD.iso / CRS / crs54.d81 / sgtool13.arc / SID.ARC / SIDPOT.C < prev    next >
C/C++ Source or Header  |  1993-08-28  |  1KB  |  43 lines

  1. /*
  2. SG C Tools 1.3
  3.  
  4. (C) 1993 Steve Goldsmith
  5. All Rights Reserved
  6.  
  7. Compiled with HI-TECH C 3.09 (CP/M-80).
  8. */
  9.  
  10. #include <sys.h>
  11. #include <hitech.h>
  12. #include <cia.h>
  13. #include <sid.h>
  14.  
  15. uchar sidPot1X;
  16. uchar sidPot1Y;
  17. uchar sidPot2X;
  18. uchar sidPot2Y;
  19.  
  20. /* read all pots.  disable interrupts before calling or cp/m's key scan */
  21. /* routine will affect values */
  22.  
  23. void getpotssid(void)
  24. {
  25.   register uchar SaveReg;
  26.  
  27.   SaveReg = inp(cia1+ciaDataDirA);    /* save data dir reg */
  28.   outp(cia1+ciaDataDirA,0xC0);        /* set bits 6 and 7 to output */
  29.   outp(cia1+ciaDataA,ciaPotsPort1);   /* set 4066 to read port 1 pots */
  30.   setintctrlcia(cia2,ciaClearIcr);    /* disable all cia 2 interrupts */
  31.   settimeracia(cia2,1636,ciaCPUOne);  /* 1.6 ms delay to get stable reading */
  32.   while ((inp(cia2+ciaIntCtrl) & 0x01) == 0);
  33.   sidPot1X = inp(sidPotX);            /* read pots */
  34.   sidPot1Y = inp(sidPotY);
  35.   outp(cia1+ciaDataA,ciaPotsPort2);   /* set 4066 to read port 2 pots */
  36.   setintctrlcia(cia2,ciaClearIcr);
  37.   settimeracia(cia2,1636,ciaCPUOne);  /* 1.6 ms delay to get stable reading */
  38.   while ((inp(cia2+ciaIntCtrl) & 0x01) == 0);
  39.   sidPot2X = inp(sidPotX);            /* read pots */
  40.   sidPot2Y = inp(sidPotY);
  41.   outp(cia1+ciaDataDirA,SaveReg);     /* restore data dir reg */
  42. }
  43.